package com.database.mapper;


import com.database.character.UserAccount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

	//查询所有用户
	@Select("select * from useraccount")
	List<UserAccount> list();

	//根据userId查询用户
	@Select("select * from useraccount where user_id = #{userId}")
	UserAccount getByUid(Integer userId);

	//根据nickname查询用户
	@Select("select * from useraccount where nickname = #{nickname}")
	UserAccount getByNickname(String nickname);

	//删除用户
	@Delete("delete from useraccount where user_id = #{userId}")
	int deleteUserByUid(Integer userId);

	//增加用户
	@Insert("insert into useraccount(nickname, password, user_type, register_time, gender, update_time,picUrl)" +
			"values (#{nickname}, #{password}, #{userType}, #{registerTime}, #{gender}, #{updateTime},#{picUrl})")
	int addUser(UserAccount userAccount);

	//修改用户
	int updateUser(UserAccount userAccount);

}
